<template>
	<view>
	<u-navbar back-text="管理员" :customBack="back" backIconColor="#fff" :backTextStyle="{'color':'#fff'}" :background="background"></u-navbar>
	<view class="content" v-if="logined">
		<view class="title">反馈信息展示</view>
		<view class="u-right-icon" @click="qingkong=true">清空</view>
			<u-modal v-model="qingkong" :show-title="false" @confirm="confirm1()" @cancel="cancel1()" :showCancelButton="true">
				<view class="u-p-30">
					是否确定清空反馈
				</view>
			</u-modal>
		<view v-for="(dy,index) in user7" :key="dy.id">
			<u-card :title="'内容:'+dy.suggestion" :sub-title="dy.time" :full="true" :border="false" :padding="20" margin="10rpx" :footBorderTop="false" :footStyle="footStyle" @click="showModal(dy.suggestion)">
				<view class="" slot="body">
					<view class="u-body-item u-flex u-border-bottom u-col-between u-p-t-0">
						<view class="u-body-item-title u-font-sm u-line-3">联系人电话：{{dy.tel}}</view>
					</view>
				</view>
			</u-card>
			<u-modal v-model="xiugai1" :show-title="false" :showCancelButton="true">
				<view class="u-p-30">{{data}}</view>
			</u-modal>
			<u-modal v-model="xiugai" :show-title="false" @confirm="confirm()" @cancel="cancel()" :showCancelButton="true">
				<view class="u-p-30">确定删除这一反馈吗？</view>
			</u-modal>
			<view class="u-right-icon" @click="showModa2(dy.id)">删除</view>
			<u-gap bgColor="#ededed" height="20"></u-gap>
		</view>
	</view>
	
	</view>
</template>

<script>
	export default {
		
		data() {
			return {
				qingkong:false,
				xiugai:false,
				xiugai1:false,
				footStyle:{
					'paddingTop':'0rpx'
				},
				user7:{
					tel:"",
					suggestion:"",
					time:"",
					id:"",
				},
				str:{
					id:"",
				},
				data:"",
				logined:true,
				background: {
					'background-image': 'linear-gradient(45deg, #2BC3C8, #84E7B9)'
				},
			}
		},
		onLoad() {
			uni.request({
				url:"http://192.168.137.139:8080/adminViewSuggestion",
				success: (res) => {
				 console.log(res)
				 this.user7=res.data.result
				}
				})
		},
		computed: {
			inputStyle() {
				let style = {};
				if(this.mobile) {
					style.color = "#fff";
					style.backgroundColor = '#2BC3C8';
				}
				return style;
			}
		},
		methods:{
			showModa2(dyid){
				this.str.id=dyid
				this.xiugai=true
			},
			showModal(dyid1){
				this.data=dyid1
				// console.log(dyid1)
				this.xiugai1 = true
				
			},
			confirm1(){
				uni.request({
				 	url:"http://192.168.137.139:8080/adminDelAllSuggestion",
					success: (res) => {
					 if (res.data.code*1==200) {
						 try{
							 console.log("反馈全部清除.....")
							 this.$u.toast("反馈全部清除.....")
							setTimeout(function(){
								uni.navigateBack()
							},1000);
							console.log("页面跳转")
							console.log(res)
						 }catch(e){
							this.$u.toast('身份信息格式异常')
						 }
					 } else{
						this.$u.toast('清空失败！')
						console.log(res)
					 }
					}
				})
			},
			confirm(){
				console.log("shshhsh")
				console.log(this.str.id)
				console.log("shshhsh")
				uni.request({
				 	url:"http://192.168.137.139:8080/adminDelSuggestion",
					method:"POST",
					data:this.str,
					success: (res) => {
					 if (res.data.code*1==200) {
						 try{
							 this.$u.toast("该反馈删除成功.....")
							setTimeout(function(){
								uni.navigateBack()
							},1000);
							console.log("页面跳转")
							console.log(res)
						 }catch(e){
							this.$u.toast('身份信息格式异常')
						 }
					 } else{
						this.$u.toast('删除失败！')
						console.log(res)
					 }
					}
				})
			},
			cancel1(){
				this.qingkong=false
			},
			cancel(){
				this.xiugai = false
			},
			toHome(){
				uni.switchTab({
					url: "/pages/mine/index"
				})
			},
			twist(){
				uni.navigateTo({
					url:"/pages/login/chaxun"
				})
			},
			back(){
				this.$common.switchTabTo('/pages/index/index');
			},
		}
		}
	
</script>

<style lang="scss" scoped>
	.content {
		margin: 80rpx 60rpx 30rpx 60rpx;
	
		.title {
			text-align: center;
			font-size: 60rpx;
			font-weight: 500;
			margin-bottom: 100rpx;
		}
	
		.getCaptcha {
			background-color: #A9FFDA;
			color: #FFFFFF;
			border: none;
			font-size: 30rpx;
			margin: 60rpx 0;
			
			&::after {
				border: none;
			}
		}
		.alternative {
			color: $u-tips-color;
			display: flex;
			justify-content: space-between;
			margin-top: 30rpx;
		}
	}
	.buttom {
		.loginType {
			display: flex;
			padding: 200rpx 150rpx 150rpx 150rpx;
			justify-content:space-between;
			
			.item {
				display: flex;
				flex-direction: column;
				align-items: center;
				color: $u-content-color;
				font-size: 28rpx;
			}
		}
		
		.hint {
			padding: 20rpx 40rpx;
			font-size: 20rpx;
			color: $u-tips-color;
			text-align: center;
			.link {
				color: $u-type-warning;
			}
		}
	}
</style>



